package me.haoliang

/**
  * 因为private[this]这家伙比private更加高阶，它只限当前的对象(就是this)使用
  * private[pakage] ,这类似于java中没有修饰符的类成员，在该包下是可以访问的
  * author: planck 
  * createTime: 2016/10/14.
  */
class PrivateScala {
  private[this] val name = "luhui"
  private val name1 = "hl"
  private[haoliang] val name2 = "planck"

  def say(): Unit = {
    println(name)
  }

  def say(a: PrivateScala): Unit = {
    //println(a.name)
    //这样就不行了
    println(a.name1)
    //这样就可以
  }

}

object PrivateScala {
  def main(args: Array[String]): Unit = {
    val privateScala = new PrivateScala
    privateScala.say()
    //privateScala.name 这样是无法访问的
    privateScala.name2 //这样可以访问
  }

}
